import { createRouter, createWebHashHistory } from "vue-router";

//1、创建路由规则(采用懒加载模式)
const routes = [
  {
    path: "/",
    redirect: "/home",
  },
  // {
  //   path: "/login",
  //   name: "login",
  //   component: () => import("../views/login/index.vue"),
  // },
  {
    path: "/layout",
    name: "layout",
    component: () => import("../views/layout/index.vue"),
    children: [
      {
        path: "/home",
        name: "home",
        component: () => import("../views/home/home.vue"),
      },
      {
        path: "/classify",
        name: "classify",
        component: () => import("../views/classify/index.vue"),
      },
      {
        path: "/videos",
        name: "videos",
        component: () => import("../views/videos/index.vue"),
      },
      {
        path: "/my",
        name: "my",
        component: () => import("../views/my/index.vue"),
      },
    ],
  },
];

//2、创建路由实例
const router = createRouter({
  //这里使用的是 URL 的 hash 路由模式 （若使用 H5 的 history 模式，就需要引入 createWebhistory）
  history: createWebHashHistory(),
  //指定路哟规则  routes:routes
  routes,
});
export default router;
